package me.banxi.mia.account.email;

import java.io.IOException;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

public class AccountEmailServiceImpl implements AccountEmailService {

	private JavaMailSender javaMailSender;
	private String systemEmail;
	
	
	public JavaMailSender getJavaMailSender() {
		return javaMailSender;
	}


	public void setJavaMailSender(JavaMailSender javaMailSender) {
		this.javaMailSender = javaMailSender;
	}


	public String getSystemEmail() {
		return systemEmail;
	}


	public void setSystemEmail(String systemEmail) {
		this.systemEmail = systemEmail;
	}


	@Override
	public void sendMail(String to)
			throws AccountEmailException, MessagingException {

		MimeMessage msg = javaMailSender.createMimeMessage();
		try {
			msg = BuildTemplateMimeMessage.getMimeMessage(to,msg);
			javaMailSender.send(msg);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

	}

}
